// pages/myMedal/myMedal.js
import { shareOptions } from "../../utils/access";
import request from "../../utils/request";
import { getStorage } from "../../utils/utils"
const api = require("../../config/api");

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userId:'',
    avatarUrl:'',
    types:[
      {
        title: '坚持分类',
        type: 'stickClassifyList',
        number1:'stickClassifyTotalNum',
        number2:'stickClassifyGetNum',
      },
      {
        title: '社交达人',
        type: 'socialTalentList',
        number1:'socialTalentTotalNum',
        number2:'socialTalentGetNum',
      },
      {
        title: '其他奖章',
        type: 'otherList',
        number1:'otherTotalNum',
        number2:'otherGetNum',
      },
    ],
    list:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let userInfo = getStorage('userInfo')
    let userId = getStorage('userId')
    this.setData({
      avatarUrl:userInfo.avatarUrl,
      userId
    })
    this.getMyModalList()
  },
  //获取勋章分组列表
  getMyModalList: async function(){
    const res = await request.get(api.getMyMedalGroup,{})
    console.log('res',res);
    if(res.httpStatus==200){
      this.setData({
        list:res.data
      })
    }
  },
  //跳转勋章详情
  toMedalDetail:function(){
    wx.navigateTo({
      url: '/pages/medalDetail/medalDetail',
    })
  },
  //跳转勋章墙
  toMedalWall:function(){
    let { userId } = this.data
    wx.navigateTo({
      url: `/pages/medalWall/medalWall?userId=${userId}`,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  // 用户点击右上角分享
	onShareAppMessage(e) {
		return shareOptions('default', e)
	},
})